
using System.Web.UI.HtmlControls;
using System;
using System.Configuration;
using System.Drawing;
using System.Data;
using System.Web.UI.WebControls;
using Microsoft.VisualBasic;
using System.Collections;
using System.Web.UI;
using System.Web;


using System.Resources;
using System.Xml;
using com.ddsc.common;
//using com.ddsc.database;
using DDSC.OracleADO;
using com.ddsc.utility;
using log4net;
using System.Text;

namespace smasb2b
{
	public class Login_pop : BasePage
	{
		public Login_pop()
		{
			// VBConversions Note: Non-static class variable initialization is below.  Class variables cannot be initially assigned non-static values in C#.
			pGUID = Guid.NewGuid().ToString();
			
		}
		
#region  Web Form 設計工具產生的程式碼
		
		//此為 Web Form 設計工具所需的呼叫。
		[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
		{
			
		}
		protected System.Web.UI.WebControls.Label lblMSG002;
		protected System.Web.UI.WebControls.Label lblMSG003;
		protected System.Web.UI.WebControls.Label lblQUERYPW;
		protected System.Web.UI.WebControls.Label lblVENDERENTER;
		protected System.Web.UI.HtmlControls.HtmlInputImage btnLogin;
		protected ddscControlLibrary.InputBoxCtrl txtVENDER_ID;
		protected ddscControlLibrary.InputBoxCtrl txtPASSWORD;
		protected System.Web.UI.HtmlControls.HtmlImage IMG2;
		protected System.Web.UI.WebControls.Label lblVENDERENTER1;
		
		//注意: 下列預留位置宣告是 Web Form 設計工具需要的項目。
		//請勿刪除或移動它。
		private System.Object designerPlaceholderDeclaration;
		
		private void Page_Init(System.Object sender, System.EventArgs e)
		{
			//CODEGEN: 此為 Web Form 設計工具所需的方法呼叫
			//請勿使用程式碼編輯器進行修改。
			InitializeComponent();
		}
		
#endregion
		public string pGUID; // VBConversions Note: Initial value cannot be assigned here since it is non-static.  Assignment has been moved to the class constructors.
		BasePage BasePage = new BasePage();
		ResourceManager rm;
		//在這裡放置使用者程式碼以初始化網頁
		
		private void Page_Load(System.Object sender, System.EventArgs e)
		{
			rm = BasePage.GetResourceManager();
		}
         
        //Tony:
        public DataSet Query_Vendor(com.ddsc.common.ddscDataSet p_ddscDt)
		//public DataSet Query_Vendor(ddscDataSet p_ddscDt)
		{
			FunctionHandler FunctionHandler = new FunctionHandler();
			DataSet dsReturn = default(DataSet);
			DataSet ds = p_ddscDt.getDataSet();
            dbAccess dba = new dbAccess();
            ArrayList m_arrParam = new ArrayList();
			string VENDOR_NO = "";
			try
			{
				string password = FunctionHandler.Encrypt(ds.Tables[0].Rows[1]["PW"].ToString());
				// 查詢資料總筆數之 sql command
				StringBuilder sb = new StringBuilder();
				VENDOR_NO = ds.Tables[0].Rows[1]["VENDOR_NO"].ToString();
				sb.Append("SELECT * FROM V_VND_VENDOR  ");
                //Tony : 1.修改SQL語法使用參數，不組字串
				sb.Append("Where PK_VENDOR_NO = :VENDOR_NO AND VENDOR_PWD = :password");
                //Tony : 2.設定動態參數物件
                m_arrParam.Add(dba.GetOracleParam(":VENDOR_NO", VENDOR_NO));
                m_arrParam.Add(dba.GetOracleParam(":password", password));				
				// DataTable Name
				string dtName = "V_VND_VENDOR";
				
				// Sql command
				string sqlCommands = sb.ToString();
				
				// create database access object
                //Tony : 3.修改執行方法Overload
				//dbAccess dba = new dbAccess();
				//dsReturn = dba.runExecuteQuery(dtName, sqlCommands);
                dsReturn = dba.runExecuteQuery(dtName, sqlCommands, m_arrParam);
				
			}
			catch (Exception ex)
			{
				// create return object (DataSet)
				dsReturn = new DataSet("V_VND_VENDOR");
				dsReturn.Tables.Add(createErrorTable(ex.Message));
				
				
			}
			
			return dsReturn;
		}
		private DataTable createErrorTable(string mError)
		{
			
			dbReturnInfo dbInfo = new dbReturnInfo("info");
			dbInfo.AddNewRow();
			dbInfo.setReturnDataValue("F", System.Convert.ToString(999), 0, mError);
			return dbInfo.getReturnDataTable();
		}
	}
	
}
